Constrain public property to specific types in List

I reckon you would need your own list implementation that is going to wrap a List where T : class { private readonly List list = new List(); public void Add(Type item) { if(!typeof(T). IsAssignableFrom(item)) { throw new InvalidOperationException(); } list. Add(item); } } Of course you would probably want to implement IList.

I reckon you would need your own list implementation that is going to wrap a List. Maybe something like this: public class TypeList where T : class { private readonly List list = new List(); public void Add(Type item) { if(!typeof(T). IsAssignableFrom(item)) { throw new InvalidOperationException(); } list.

Add(item); } } Of course you would probably want to implement IList and then simply delegate the methods to the list.

You could define a new collection type CustomList that derives from List and adds the type constraint, and then use this in place of List in your class. Public class CustomList : List where T : ICustomInterface { ... }.

Please note: I am not looking to provide a List OF instances that implement a specific type. I am looking to provide a List OF Types that implement a specific interface. There's no quick 'n' easy way to do this.

You'll have to implement your own collection class, override the add method and then check to see if the type implements your interface via reflection... class myTypeCollection : List { override void Add(Type t) { if (t. GetInterface(typeof(MyCustomInterface)) == null) throw new InvalidOperationException("Type does not implement MyCustomInterface"); base. Add(t); } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.